package com.controller;

import java.awt.EventQueue;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.WindowEvent;
import java.awt.event.WindowListener;
import java.util.Observable;
import java.util.Observer;

import com.view.TelaGraf;

public class GrafController extends Observable implements ActionListener, WindowListener{
	
	private static GrafController grafCont;
	public TelaGraf view;
	
	public GrafController(Observer obs){
		addObserver(obs);
		grafCont = this;
		EventQueue.invokeLater(new Runnable() {			
			@Override
			public void run() {
				view = new TelaGraf();
				view.setVisible(true);
				view.setAcListener(grafCont);
				view.addWindowListener(grafCont);
				view.updateValoresDiarios();
				//view.cbDesc.grabFocus();  criar depois
			}

		});
	}

	@Override
	public void windowActivated(WindowEvent arg0) {}

	@Override
	public void windowClosed(WindowEvent arg0) {}

	@Override
	public void windowClosing(WindowEvent arg0) {}

	@Override
	public void windowDeactivated(WindowEvent arg0) {}

	@Override
	public void windowDeiconified(WindowEvent arg0) {}

	@Override
	public void windowIconified(WindowEvent arg0) {}

	@Override
	public void windowOpened(WindowEvent arg0) {}

	@Override
	public void actionPerformed(ActionEvent arg) {
		Object source = arg.getSource();
		if(source == view.btSemanalGrafo){
			System.out.println("AA");
		}
		if(source == view.btSemanalPizza){
			//view.removeAll();
			//view.revalidate();
			//view.repaint();
			System.out.println("B");
		}
	}

}
